package com.huike.controller.notic;

import com.huike.dto.ActivityDto;
import com.huike.dto.NoticeDto;
import com.huike.entity.Notice;
import com.huike.result.PageResult;
import com.huike.result.Result;
import com.huike.service.NoticeService;
import com.huike.utils.BaseContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 通知公告表 前端控制器
 * </p>
 *
 * @author itheima
 */
@Slf4j
@RestController
@RequestMapping("/system/notic")
public class NoticController {
    @Autowired
    private NoticeService noticeService;

    /**
     * 分页
     * @param dto
     * @return
     */
    @GetMapping("/page")
    public Result<PageResult> findAll(NoticeDto dto) {
        PageResult pageResult = noticeService.findAll(dto);
        return Result.success(pageResult);
    }

    /**
     * 提示信息
     * @param status
     * @return
     */
    @GetMapping("/list")
    public Result check(@PathVariable String status){
        List<Notice> noticeList = noticeService.check(BaseContext.getCurrentId(),status);
        return Result.success(noticeList);
    }
/**
 * 获取活动相信信息
 */
@GetMapping("/noticed")
public Result getInfo(@PathVariable Long id){
return noticeService.getInfo(id);
}

/**
 * 修改为已读
 */
@PutMapping("/update")
public Result update(@PathVariable NoticeDto dto){
    noticeService.updateInfo(dto);
    return Result.success();
}
}
